package com.qipay.baas.mapper;

import com.qipay.baas.model.Dictionary;
import com.qipay.baas.model.DictionaryExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.session.RowBounds;
import org.apache.ibatis.type.JdbcType;

public interface DictionaryMapper {
    @SelectProvider(type=DictionarySqlProvider.class, method="countByExample")
    int countByExample(DictionaryExample example);

    @DeleteProvider(type=DictionarySqlProvider.class, method="deleteByExample")
    int deleteByExample(DictionaryExample example);

    @Delete({
        "delete from `dictionary`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into `dictionary` (`dict_Type`, `dict_value`, ",
        "`dict_name`, `mark`, `Parent_Code`)",
        "values (#{dictType,jdbcType=CHAR}, #{dictValue,jdbcType=INTEGER}, ",
        "#{dictName,jdbcType=VARCHAR}, #{mark,jdbcType=CHAR}, #{parentCode,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(Dictionary record);

    @InsertProvider(type=DictionarySqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(Dictionary record);

    @SelectProvider(type=DictionarySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="dict_Type", property="dictType", jdbcType=JdbcType.CHAR),
        @Result(column="dict_value", property="dictValue", jdbcType=JdbcType.INTEGER),
        @Result(column="dict_name", property="dictName", jdbcType=JdbcType.VARCHAR),
        @Result(column="mark", property="mark", jdbcType=JdbcType.CHAR),
        @Result(column="Parent_Code", property="parentCode", jdbcType=JdbcType.INTEGER)
    })
    List<Dictionary> selectByExampleWithRowbounds(DictionaryExample example, RowBounds rowBounds);

    @SelectProvider(type=DictionarySqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="dict_Type", property="dictType", jdbcType=JdbcType.CHAR),
        @Result(column="dict_value", property="dictValue", jdbcType=JdbcType.INTEGER),
        @Result(column="dict_name", property="dictName", jdbcType=JdbcType.VARCHAR),
        @Result(column="mark", property="mark", jdbcType=JdbcType.CHAR),
        @Result(column="Parent_Code", property="parentCode", jdbcType=JdbcType.INTEGER)
    })
    List<Dictionary> selectByExample(DictionaryExample example);

    @Select({
        "select",
        "`id`, `dict_Type`, `dict_value`, `dict_name`, `mark`, `Parent_Code`",
        "from `dictionary`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="dict_Type", property="dictType", jdbcType=JdbcType.CHAR),
        @Result(column="dict_value", property="dictValue", jdbcType=JdbcType.INTEGER),
        @Result(column="dict_name", property="dictName", jdbcType=JdbcType.VARCHAR),
        @Result(column="mark", property="mark", jdbcType=JdbcType.CHAR),
        @Result(column="Parent_Code", property="parentCode", jdbcType=JdbcType.INTEGER)
    })
    Dictionary selectByPrimaryKey(Long id);

    @UpdateProvider(type=DictionarySqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Dictionary record, @Param("example") DictionaryExample example);

    @UpdateProvider(type=DictionarySqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Dictionary record, @Param("example") DictionaryExample example);

    @UpdateProvider(type=DictionarySqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Dictionary record);

    @Update({
        "update `dictionary`",
        "set `dict_Type` = #{dictType,jdbcType=CHAR},",
          "`dict_value` = #{dictValue,jdbcType=INTEGER},",
          "`dict_name` = #{dictName,jdbcType=VARCHAR},",
          "`mark` = #{mark,jdbcType=CHAR},",
          "`Parent_Code` = #{parentCode,jdbcType=INTEGER}",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Dictionary record);
}